{
	name:"CutLine",
	tool:"./paint_tool/lines/cut-line.shape",
	onInit(){
		this.ctrlIndex = 3
	},
	onClick(pos,e,meta){
		if(!this.step.isEmpty()){
			this.onCommit(pos)
			return
		}
		this.onChooseTarget(pos)
	},
	onChooseTarget(pos){
		let path = this.queryCircles(pos)
		if(path){
			this.loadMngByAction(path.action)
				.pathFocus(path)
			let cp = this.loadMngByAction(path.action).getCircleMeta(path)
			this.step.push(cp)
			this.toast("请再点击圆外一点")
		}else
		this.toast("请点击圆形路径边框")
	},
	onCommit(pos){
		let target = this.step[0]
		let dis = Math.distance(target,pos)
		if(dis<=target.r){
			this.toast("请点击圆外一点")
			return false
		}

		this.step.push(pos)
		this.commit()
		this.target = null
	},
	onMousemove(pos){
		let cp = this.step[0]
		if(!cp)return
		let state = this.getContextState()
		let steps = this.getPoints([cp,pos])
			steps[0].text=""
		this.clearRect()
		this.draw({
			step:steps,
			state
		})
	},
	getPoints(ps){
		let step = Math.calcCutPos(ps[0],ps[1])
			step[0].move=false
			step[1].move=false
		return [ps[1],...step].map((p,i)=>this.newPoint(p,i))
	},
	getLineMeta(stepData,pos){
		let ps = stepData.step
		let steps = [ps[1],ps[0],ps[2]]
		return Math.getLineMeta(steps,pos)
	}
}